<!DOCTYPE html>
<html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
  <meta name="description" content="刘清政">
  <meta name="keyword" content="hexo-theme">
  
    <link rel="shortcut icon" href="/css/images/logo.png">
  
  <title>
    
      db/MySQL系列/09-MySQL系列之-主从复制进阶 | Justin-刘清政的博客
    
  </title>
  <link href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
  <link href="//cdnjs.cloudflare.com/ajax/libs/nprogress/0.2.0/nprogress.min.css" rel="stylesheet">
  <link href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/tomorrow.min.css" rel="stylesheet">
  
<link rel="stylesheet" href="/css/style.css">

  
    
<link rel="stylesheet" href="/css/plugins/gitment.css">

  
  <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="//cdnjs.cloudflare.com/ajax/libs/geopattern/1.2.3/js/geopattern.min.js"></script>
  <script src="//cdnjs.cloudflare.com/ajax/libs/nprogress/0.2.0/nprogress.min.js"></script>
  
    
<script src="/js/qrious.js"></script>

  
  
    
<script src="/js/gitment.js"></script>

  
  

  
<meta name="generator" content="Hexo 4.2.0"></head>
<div class="wechat-share">
  <img src="/css/images/logo.png" />
</div>

  <body>
    <header class="header fixed-header">
  <div class="header-container">
    <a class="home-link" href="/">
      <div class="logo"></div>
      <span>Justin-刘清政的博客</span>
    </a>
    <ul class="right-list">
      
        <li class="list-item">
          
            <a href="/" class="item-link">主页</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/tags/" class="item-link">标签</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/archives/" class="item-link">归档</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/about/" class="item-link">关于我</a>
          
        </li>
      
    </ul>
    <div class="menu">
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
    </div>
    <div class="menu-mask">
      <ul class="menu-list">
        
          <li class="menu-item">
            
              <a href="/" class="menu-link">主页</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/tags/" class="menu-link">标签</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/archives/" class="menu-link">归档</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/about/" class="menu-link">关于我</a>
            
          </li>
        
      </ul>
    </div>
  </div>
</header>

    <div id="article-banner">
  <h2>db/MySQL系列/09-MySQL系列之-主从复制进阶</h2>



  <p class="post-date">2019-12-24</p>
    <!-- 不蒜子统计 -->
    <span id="busuanzi_container_page_pv" style='display:none' class="">
        <i class="icon-smile icon"></i> 阅读数：<span id="busuanzi_value_page_pv"></span>次
    </span>
  <div class="arrow-down">
    <a href="javascript:;"></a>
  </div>
</div>
<main class="app-body flex-box">
  <!-- Article START -->
  <article class="post-article">
    <section class="markdown-content"><h1 id="1-延时从库"><a href="#1-延时从库" class="headerlink" title="1. 延时从库"></a>1. 延时从库</h1><h2 id="1-1介绍"><a href="#1-1介绍" class="headerlink" title="1.1介绍"></a>1.1介绍</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">是我们认为配置的一种特殊从库.人为配置从库和主库延时N小时.</span><br></pre></td></tr></table></figure>

<h2 id="1-2-为什么要有延时从"><a href="#1-2-为什么要有延时从" class="headerlink" title="1.2 为什么要有延时从"></a>1.2 为什么要有延时从</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">数据库故障?</span><br><span class="line">物理损坏</span><br><span class="line">主从复制非常擅长解决物理损坏.</span><br><span class="line">逻辑损坏</span><br><span class="line">普通主从复制没办法解决逻辑损坏</span><br></pre></td></tr></table></figure>

<h2 id="1-3-配置延时从库"><a href="#1-3-配置延时从库" class="headerlink" title="1.3 配置延时从库"></a>1.3 配置延时从库</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">SQL线程延时:数据已经写入relaylog中了,SQL线程<span class="string">"慢点"</span>运行</span><br><span class="line">一般企业建议<span class="number">3</span><span class="number">-6</span>小时,具体看公司运维人员对于故障的反应时间</span><br><span class="line"></span><br><span class="line">mysql&gt;stop slave;</span><br><span class="line">mysql&gt;CHANGE MASTER TO MASTER_DELAY = <span class="number">300</span>;</span><br><span class="line">mysql&gt;start slave;</span><br><span class="line">mysql&gt; show slave status \G</span><br><span class="line">SQL_Delay: <span class="number">300</span></span><br><span class="line">SQL_Remaining_Delay: <span class="literal">NULL</span></span><br></pre></td></tr></table></figure>

<h2 id="1-4-延时从库应用"><a href="#1-4-延时从库应用" class="headerlink" title="1.4 延时从库应用"></a>1.4 延时从库应用</h2><h3 id="1-4-1-故障恢复思路"><a href="#1-4-1-故障恢复思路" class="headerlink" title="1.4.1 故障恢复思路"></a>1.4.1 故障恢复思路</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">1主1从,从库延时5分钟,主库误删除1个库</span><br><span class="line">1. 5分钟之内 侦测到误删除操作</span><br><span class="line">2. 停从库SQL线程</span><br><span class="line">3. 截取relaylog</span><br><span class="line">起点 :停止SQL线程时,relay最后应用位置</span><br><span class="line">终点:误删除之前的position(GTID)</span><br><span class="line">4. 恢复截取的日志到从库</span><br><span class="line">5. 从库身份解除,替代主库工作</span><br></pre></td></tr></table></figure>

<h3 id="1-4-2-故障模拟及恢复"><a href="#1-4-2-故障模拟及恢复" class="headerlink" title="1.4.2 故障模拟及恢复"></a>1.4.2 故障模拟及恢复</h3><figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">1.主库数据操作</span><br><span class="line"><span class="selector-tag">db01</span> <span class="selector-attr">[(none)]</span>&gt;<span class="selector-tag">create</span> <span class="selector-tag">database</span> <span class="selector-tag">relay</span> <span class="selector-tag">charset</span> <span class="selector-tag">utf8</span>;</span><br><span class="line"><span class="selector-tag">db01</span> <span class="selector-attr">[(none)]</span>&gt;<span class="selector-tag">use</span> <span class="selector-tag">relay</span></span><br><span class="line"><span class="selector-tag">db01</span> <span class="selector-attr">[relay]</span>&gt;<span class="selector-tag">create</span> <span class="selector-tag">table</span> <span class="selector-tag">t1</span> (<span class="selector-tag">id</span> <span class="selector-tag">int</span>);</span><br><span class="line"><span class="selector-tag">db01</span> <span class="selector-attr">[relay]</span>&gt;<span class="selector-tag">insert</span> <span class="selector-tag">into</span> <span class="selector-tag">t1</span> <span class="selector-tag">values</span>(1);</span><br><span class="line"><span class="selector-tag">db01</span> <span class="selector-attr">[relay]</span>&gt;<span class="selector-tag">drop</span> <span class="selector-tag">database</span> <span class="selector-tag">relay</span>;</span><br></pre></td></tr></table></figure>



<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">2. 停止从库SQL线程</span><br><span class="line">stop slave sql_thread;</span><br></pre></td></tr></table></figure>



<figure class="highlight kotlin"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">3</span>. 找relaylog的截取起点和终点</span><br><span class="line">起点:</span><br><span class="line">Relay_Log_File: db01-relay-bin<span class="number">.000002</span></span><br><span class="line">Relay_Log_Pos: <span class="number">482</span></span><br><span class="line">终点:</span><br><span class="line">show relaylog events <span class="keyword">in</span> <span class="string">'db01-relay-bin.000002'</span></span><br><span class="line">| db01-relay-bin<span class="number">.000002</span> | <span class="number">1046</span> | Xid            |         <span class="number">7</span> |        <span class="number">2489</span> | COMMIT <span class="comment">/* xid=144 */</span>                  |</span><br><span class="line">| db01-relay-bin<span class="number">.000002</span> | <span class="number">1077</span> | Anonymous_Gtid |         <span class="number">7</span> |        <span class="number">2554</span> | SET @<span class="meta">@SESSION</span>.GTID_NEXT= <span class="string">'ANONYMOUS'</span>  |</span><br><span class="line">mysqlbinlog --start-position=<span class="number">482</span> --stop-position=<span class="number">1077</span>  /<span class="keyword">data</span>/<span class="number">3308</span>/<span class="keyword">data</span>/db01-relay-bin<span class="number">.000002</span>&gt;/tmp/relay.sql</span><br></pre></td></tr></table></figure>

<ol>
<li>从库恢复relaylog</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">source</span> /tmp/relay.sql</span><br></pre></td></tr></table></figure>

<p>5.从库身份解除</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">db01</span> <span class="selector-attr">[relay]</span>&gt;<span class="selector-tag">stop</span> <span class="selector-tag">slave</span>;</span><br><span class="line"><span class="selector-tag">db01</span> <span class="selector-attr">[relay]</span>&gt;<span class="selector-tag">reset</span> <span class="selector-tag">slave</span> <span class="selector-tag">all</span></span><br></pre></td></tr></table></figure>

<h1 id="2-半同步"><a href="#2-半同步" class="headerlink" title="2. 半同步            ***"></a>2. 半同步            ***</h1><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">解决主从数据一致性问题</span><br></pre></td></tr></table></figure>

<h2 id="2-1-半同步复制工作原理的变化"><a href="#2-1-半同步复制工作原理的变化" class="headerlink" title="2.1 半同步复制工作原理的变化"></a>2.1 半同步复制工作原理的变化</h2><figure class="highlight dart"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">1.</span> 主库执行新的事务,commit时,更新 <span class="keyword">show</span> master  status\G ,触发一个信号给</span><br><span class="line"><span class="number">2.</span> binlog dump 接收到主库的 <span class="keyword">show</span> master status\G信息,通知从库日志更新了</span><br><span class="line"><span class="number">3.</span> 从库IO线程请求新的二进制日志事件</span><br><span class="line"><span class="number">4.</span> 主库会通过dump线程传送新的日志事件,给从库IO线程</span><br><span class="line"><span class="number">5.</span> 从库IO线程接收到binlog日志,当日志写入到磁盘上的relaylog文件时,给主库ACK_receiver线程</span><br><span class="line"><span class="number">6.</span> ACK_receiver线程触发一个事件,告诉主库commit可以成功了</span><br><span class="line"><span class="number">7.</span> 如果ACK达到了我们预设值的超时时间,半同步复制会切换为原始的异步复制.</span><br></pre></td></tr></table></figure>

<h2 id="2-2-配置半同步复制"><a href="#2-2-配置半同步复制" class="headerlink" title="2.2 配置半同步复制"></a>2.2 配置半同步复制</h2><figure class="highlight dart"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">加载插件</span><br><span class="line">主:</span><br><span class="line">INSTALL PLUGIN rpl_semi_sync_master SONAME <span class="string">'semisync_master.so'</span>;</span><br><span class="line">从:</span><br><span class="line">INSTALL PLUGIN rpl_semi_sync_slave SONAME <span class="string">'semisync_slave.so'</span>;</span><br><span class="line">查看是否加载成功:</span><br><span class="line"><span class="keyword">show</span> plugins;</span><br><span class="line">启动:</span><br><span class="line">主:</span><br><span class="line">SET GLOBAL rpl_semi_sync_master_enabled = <span class="number">1</span>;</span><br><span class="line">从:</span><br><span class="line">SET GLOBAL rpl_semi_sync_slave_enabled = <span class="number">1</span>;</span><br><span class="line">重启从库上的IO线程</span><br><span class="line">STOP SLAVE IO_THREAD;</span><br><span class="line">START SLAVE IO_THREAD;</span><br><span class="line">查看是否在运行</span><br><span class="line">主:</span><br><span class="line"><span class="keyword">show</span> status like <span class="string">'Rpl_semi_sync_master_status'</span>;</span><br><span class="line">从:</span><br><span class="line"><span class="keyword">show</span> status like <span class="string">'Rpl_semi_sync_slave_status'</span>;</span><br></pre></td></tr></table></figure>

<h1 id="3-过滤复制"><a href="#3-过滤复制" class="headerlink" title="3 . 过滤复制"></a>3 . 过滤复制</h1><h2 id="3-1-说明"><a href="#3-1-说明" class="headerlink" title="3.1 说明"></a>3.1 说明</h2><p>主库：</p>
<figure class="highlight dart"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">show</span> master status;</span><br><span class="line">Binlog_Do_DB</span><br><span class="line">Binlog_Ignore_DB</span><br></pre></td></tr></table></figure>

<p>从库：</p>
<figure class="highlight dart"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">show</span> slave status\G</span><br><span class="line">Replicate_Do_DB: </span><br><span class="line">Replicate_Ignore_DB:</span><br></pre></td></tr></table></figure>

<p>3.2 实现过程</p>
<figure class="highlight csharp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line">mysqldump -S /data/<span class="number">3307</span>/mysql.sock -A --master-data=<span class="number">2</span> --single-transaction  -R --triggers &gt;/backup/full.sql</span><br><span class="line"></span><br><span class="line">vim  /backup/full.sql</span><br><span class="line">-- CHANGE MASTER TO MASTER_LOG_FILE=<span class="string">'mysql-bin.000002'</span>, MASTER_LOG_POS=<span class="number">154</span>;</span><br><span class="line"></span><br><span class="line">[<span class="meta">root@db01 ~</span>]<span class="meta"># mysql -S /data/3309/mysql.sock </span></span><br><span class="line">source /backup/full.sql</span><br><span class="line"></span><br><span class="line">CHANGE MASTER TO</span><br><span class="line">MASTER_HOST=<span class="string">'10.0.0.51'</span>,</span><br><span class="line">MASTER_USER=<span class="string">'repl'</span>,</span><br><span class="line">MASTER_PASSWORD=<span class="string">'123'</span>,</span><br><span class="line">MASTER_PORT=<span class="number">3307</span>,</span><br><span class="line">MASTER_LOG_FILE=<span class="string">'mysql-bin.000002'</span>,</span><br><span class="line">MASTER_LOG_POS=<span class="number">154</span>,</span><br><span class="line">MASTER_CONNECT_RETRY=<span class="number">10</span>;</span><br><span class="line">start  slave;</span><br><span class="line">[<span class="meta">root@db01 ~</span>]<span class="meta"># vim /data/3309/my.cnf </span></span><br><span class="line">replicate_do_db=ppt</span><br><span class="line">replicate_do_db=word</span><br><span class="line">[<span class="meta">root@db01 ~</span>]<span class="meta"># systemctl restart mysqld3309</span></span><br><span class="line"></span><br><span class="line">主库：</span><br><span class="line">Master [(none)]&gt;create database word;</span><br><span class="line">Query OK, <span class="number">1</span> <span class="function">row <span class="title">affected</span> (<span class="params"><span class="number">0.00</span> sec</span>)</span></span><br><span class="line"><span class="function">Master [(<span class="params">none</span>)]&gt;create database ppt</span>;</span><br><span class="line">Query OK, <span class="number">1</span> <span class="function">row <span class="title">affected</span> (<span class="params"><span class="number">0.00</span> sec</span>)</span></span><br><span class="line"><span class="function">Master [(<span class="params">none</span>)]&gt;create database excel</span>;</span><br><span class="line">Query OK, <span class="number">1</span> <span class="function">row <span class="title">affected</span> (<span class="params"><span class="number">0.01</span> sec</span>)</span></span><br></pre></td></tr></table></figure>

<h1 id="4-GTID复制"><a href="#4-GTID复制" class="headerlink" title="4. GTID复制"></a>4. GTID复制</h1><h2 id="4-1-GTID引入"><a href="#4-1-GTID引入" class="headerlink" title="4.1  GTID引入"></a>4.1  GTID引入</h2><h2 id="4-2-GTID介绍"><a href="#4-2-GTID介绍" class="headerlink" title="4.2 GTID介绍"></a>4.2 GTID介绍</h2><figure class="highlight objectivec"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">GTID(Global Transaction ID)是对于一个已提交事务的唯一编号，并且是一个全局(主从复制)唯一的编号。</span><br><span class="line">它的官方定义如下：</span><br><span class="line">GTID = source_id ：transaction_id</span><br><span class="line"><span class="number">7E11</span>FA47<span class="number">-31</span>CA<span class="number">-19E1</span><span class="number">-9E56</span>-C43AA21293967:<span class="number">29</span></span><br><span class="line">什么是sever_uuid，和Server-<span class="keyword">id</span> 区别？</span><br><span class="line">核心特性: 全局唯一,具备幂等性</span><br></pre></td></tr></table></figure>

<h1 id="4-3-GTID核心参数"><a href="#4-3-GTID核心参数" class="headerlink" title="4.3 GTID核心参数"></a>4.3 GTID核心参数</h1><p>重要参数：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">gtid-mode=on</span><br><span class="line">enforce-gtid-consistency=<span class="literal">true</span></span><br><span class="line"><span class="built_in">log</span>-slave-updates=1</span><br><span class="line"></span><br><span class="line">gtid-mode=on                        --启用gtid类型，否则就是普通的复制架构</span><br><span class="line">enforce-gtid-consistency=<span class="literal">true</span>               --强制GTID的一致性</span><br><span class="line"><span class="built_in">log</span>-slave-updates=1                 --slave更新是否记入日志</span><br></pre></td></tr></table></figure>

<h2 id="4-4-GTID复制配置过程："><a href="#4-4-GTID复制配置过程：" class="headerlink" title="4.4  GTID复制配置过程："></a>4.4  GTID复制配置过程：</h2><h3 id="4-4-1-清理环境"><a href="#4-4-1-清理环境" class="headerlink" title="4.4.1 清理环境"></a>4.4.1 清理环境</h3><figure class="highlight kotlin"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">pkill mysqld</span><br><span class="line"> \rm -rf /<span class="keyword">data</span>/mysql/<span class="keyword">data</span><span class="comment">/*</span></span><br><span class="line"><span class="comment"> \rm -rf /data/binlog<span class="comment">/*</span></span></span><br></pre></td></tr></table></figure>

<h3 id="4-4-2-准备配置文件"><a href="#4-4-2-准备配置文件" class="headerlink" title="4.4.2 准备配置文件"></a>4.4.2 准备配置文件</h3><figure class="highlight kotlin"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br></pre></td><td class="code"><pre><span class="line">主库db01：</span><br><span class="line">cat &gt; /etc/my.cnf &lt;&lt;EOF</span><br><span class="line">[mysqld]</span><br><span class="line">basedir=/<span class="keyword">data</span>/mysql/</span><br><span class="line">datadir=/<span class="keyword">data</span>/mysql/<span class="keyword">data</span></span><br><span class="line">socket=/tmp/mysql.sock</span><br><span class="line">server_id=<span class="number">51</span></span><br><span class="line">port=<span class="number">3306</span></span><br><span class="line">secure-file-priv=/tmp</span><br><span class="line">autocommit=<span class="number">0</span></span><br><span class="line">log_bin=/<span class="keyword">data</span>/binlog/mysql-bin</span><br><span class="line">binlog_format=row</span><br><span class="line">gtid-mode=on</span><br><span class="line">enforce-gtid-consistency=<span class="literal">true</span></span><br><span class="line">log-slave-updates=<span class="number">1</span></span><br><span class="line">[mysql]</span><br><span class="line">prompt=db01 [\\d]&gt;</span><br><span class="line">EOF</span><br><span class="line"></span><br><span class="line">slave1(db02)：</span><br><span class="line">cat &gt; /etc/my.cnf &lt;&lt;EOF</span><br><span class="line">[mysqld]</span><br><span class="line">basedir=/<span class="keyword">data</span>/mysql</span><br><span class="line">datadir=/<span class="keyword">data</span>/mysql/<span class="keyword">data</span></span><br><span class="line">socket=/tmp/mysql.sock</span><br><span class="line">server_id=<span class="number">52</span></span><br><span class="line">port=<span class="number">3306</span></span><br><span class="line">secure-file-priv=/tmp</span><br><span class="line">autocommit=<span class="number">0</span></span><br><span class="line">log_bin=/<span class="keyword">data</span>/binlog/mysql-bin</span><br><span class="line">binlog_format=row</span><br><span class="line">gtid-mode=on</span><br><span class="line">enforce-gtid-consistency=<span class="literal">true</span></span><br><span class="line">log-slave-updates=<span class="number">1</span></span><br><span class="line">[mysql]</span><br><span class="line">prompt=db02 [\\d]&gt;</span><br><span class="line">EOF</span><br><span class="line"></span><br><span class="line">slave2(db03)：</span><br><span class="line">cat &gt; /etc/my.cnf &lt;&lt;EOF</span><br><span class="line">[mysqld]</span><br><span class="line">basedir=/<span class="keyword">data</span>/mysql</span><br><span class="line">datadir=/<span class="keyword">data</span>/mysql/<span class="keyword">data</span></span><br><span class="line">socket=/tmp/mysql.sock</span><br><span class="line">server_id=<span class="number">53</span></span><br><span class="line">port=<span class="number">3306</span></span><br><span class="line">secure-file-priv=/tmp</span><br><span class="line">autocommit=<span class="number">0</span></span><br><span class="line">log_bin=/<span class="keyword">data</span>/binlog/mysql-bin</span><br><span class="line">binlog_format=row</span><br><span class="line">gtid-mode=on</span><br><span class="line">enforce-gtid-consistency=<span class="literal">true</span></span><br><span class="line">log-slave-updates=<span class="number">1</span></span><br><span class="line">[mysql]</span><br><span class="line">prompt=db03 [\\d]&gt;</span><br><span class="line">EOF</span><br></pre></td></tr></table></figure>

<h3 id="4-4-3-初始化数据"><a href="#4-4-3-初始化数据" class="headerlink" title="4.4.3 初始化数据"></a>4.4.3 初始化数据</h3><figure class="highlight kotlin"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mysqld --initialize-insecure --user=mysql --basedir=/<span class="keyword">data</span>/mysql  --datadir=/<span class="keyword">data</span>/mysql/<span class="keyword">data</span></span><br></pre></td></tr></table></figure>

<h3 id="4-4-4-启动数据库"><a href="#4-4-4-启动数据库" class="headerlink" title="4.4.4 启动数据库"></a>4.4.4 启动数据库</h3><figure class="highlight kotlin"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">/etc/<span class="keyword">init</span>.d/mysqld start</span><br></pre></td></tr></table></figure>

<h3 id="4-4-5-构建主从："><a href="#4-4-5-构建主从：" class="headerlink" title="4.4.5 构建主从："></a>4.4.5 构建主从：</h3><figure class="highlight csharp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">master:<span class="number">51</span></span><br><span class="line">slave:<span class="number">52</span>,<span class="number">53</span></span><br><span class="line"></span><br><span class="line"><span class="number">51</span>:</span><br><span class="line">grant replication slave  <span class="keyword">on</span> *.* to repl@<span class="string">'10.0.0.%'</span> identified <span class="keyword">by</span> <span class="string">'123'</span>;</span><br><span class="line"></span><br><span class="line"><span class="number">52</span>\<span class="number">53</span>:</span><br><span class="line">change master to </span><br><span class="line">master_host=<span class="string">'10.0.0.51'</span>,</span><br><span class="line">master_user=<span class="string">'repl'</span>,</span><br><span class="line">master_password=<span class="string">'123'</span> ,</span><br><span class="line">MASTER_AUTO_POSITION=<span class="number">1</span>;</span><br><span class="line"></span><br><span class="line">start slave;</span><br></pre></td></tr></table></figure>

<h2 id="4-5-GTID-从库误写入操作处理"><a href="#4-5-GTID-从库误写入操作处理" class="headerlink" title="4.5 GTID 从库误写入操作处理"></a>4.5 GTID 从库误写入操作处理</h2><figure class="highlight rust"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">查看监控信息:</span><br><span class="line">Last_SQL_Error: Error <span class="symbol">'Can</span><span class="symbol">'t</span> create database <span class="symbol">'oldboy</span>'; database exists' on query. <span class="built_in">Default</span> database: <span class="symbol">'oldboy</span>'. Query: <span class="symbol">'create</span> database oldboy'</span><br><span class="line"></span><br><span class="line">Retrieved_Gtid_Set: <span class="number">71</span>bfa52e-<span class="number">4</span>aae-<span class="number">11e9</span>-ab8c-<span class="number">000</span>c293b577e:<span class="number">1</span>-<span class="number">3</span></span><br><span class="line">Executed_Gtid_Set:  <span class="number">71</span>bfa52e-<span class="number">4</span>aae-<span class="number">11e9</span>-ab8c-<span class="number">000</span>c293b577e:<span class="number">1</span>-<span class="number">2</span>,</span><br><span class="line"><span class="number">7</span>ca4a2b7-<span class="number">4</span>aae-<span class="number">11e9</span>-<span class="number">859</span>d-<span class="number">000</span>c298720f6:<span class="number">1</span></span><br><span class="line"></span><br><span class="line">注入空事物的方法：</span><br><span class="line"></span><br><span class="line">stop slave;</span><br><span class="line">set gtid_next='<span class="number">99279e1</span>e-<span class="number">61</span>b7-<span class="number">11e9</span>-a9fc-<span class="number">000</span>c2928f5dd:<span class="number">3</span>';</span><br><span class="line">begin;commit;</span><br><span class="line">set gtid_next=<span class="symbol">'AUTOMATIC</span>';</span><br><span class="line">    </span><br><span class="line">这里的xxxxx:N 也就是你的slave sql thread报错的GTID，或者说是你想要跳过的GTID。</span><br><span class="line">最好的解决方案：重新构建主从环境</span><br></pre></td></tr></table></figure>

<h2 id="4-6-GTID-复制和普通复制的区别"><a href="#4-6-GTID-复制和普通复制的区别" class="headerlink" title="4.6  GTID 复制和普通复制的区别"></a>4.6  GTID 复制和普通复制的区别</h2><figure class="highlight dart"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">CHANGE MASTER TO</span><br><span class="line">MASTER_HOST=<span class="string">'10.0.0.51'</span>,</span><br><span class="line">MASTER_USER=<span class="string">'repl'</span>,</span><br><span class="line">MASTER_PASSWORD=<span class="string">'123'</span>,</span><br><span class="line">MASTER_PORT=<span class="number">3307</span>,</span><br><span class="line">MASTER_LOG_FILE=<span class="string">'mysql-bin.000001'</span>,</span><br><span class="line">MASTER_LOG_POS=<span class="number">444</span>,</span><br><span class="line">MASTER_CONNECT_RETRY=<span class="number">10</span>;</span><br><span class="line"></span><br><span class="line">change master to </span><br><span class="line">master_host=<span class="string">'10.0.0.51'</span>,</span><br><span class="line">master_user=<span class="string">'repl'</span>,</span><br><span class="line">master_password=<span class="string">'123'</span> ,</span><br><span class="line">MASTER_AUTO_POSITION=<span class="number">1</span>;</span><br><span class="line">start slave;</span><br><span class="line"></span><br><span class="line">（<span class="number">0</span>）在主从复制环境中，主库发生过的事务，在全局都是由唯一GTID记录的，更方便Failover</span><br><span class="line">（<span class="number">1</span>）额外功能参数（<span class="number">3</span>个）</span><br><span class="line">（<span class="number">2</span>）change master to 的时候不再需要binlog 文件名和position号,MASTER_AUTO_POSITION=<span class="number">1</span>;</span><br><span class="line">（<span class="number">3</span>）在复制过程中，从库不再依赖master.info文件，而是直接读取最后一个relaylog的 GTID号</span><br><span class="line">（<span class="number">4</span>） mysqldump备份时，默认会将备份中包含的事务操作，以以下方式</span><br><span class="line">    SET @<span class="meta">@GLOBAL</span>.GTID_PURGED=<span class="string">'8c49d7ec-7e78-11e8-9638-000c29ca725d:1'</span>;</span><br><span class="line">    告诉从库，我的备份中已经有以上事务，你就不用运行了，直接从下一个GTID开始请求binlog就行。</span><br></pre></td></tr></table></figure>



<p>24人点赞</p>
<p><a href="">老男孩-MySQL-标杆班级在线笔记</a></p>
<p>作者：wwwoldguocom<br>链接：<a href="https://www.jianshu.com/p/82bc8ed98e7f" target="_blank" rel="noopener">https://www.jianshu.com/p/82bc8ed98e7f</a><br>来源：简书<br>著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。</p>
</section>
    <!-- Tags START -->
    
    <!-- Tags END -->
    <!-- NAV START -->
    
  <div class="nav-container">
    <!-- reverse left and right to put prev and next in a more logic postition -->
    
      <a class="nav-left" href="/db/MySQL%E7%B3%BB%E5%88%97/12-MySQL%E7%B3%BB%E5%88%97%E4%B9%8B-MyCat/">
        <span class="nav-arrow">← </span>
        
          db/MySQL系列/12-MySQL系列之-MyCat
        
      </a>
    
    
      <a class="nav-right" href="/db/MySQL%E7%B3%BB%E5%88%97/07-MySQL%E7%B3%BB%E5%88%97%E4%B9%8B-%E5%A4%87%E4%BB%BD%E6%81%A2%E5%A4%8D/">
        
          db/MySQL系列/07-MySQL系列之-备份恢复
        
        <span class="nav-arrow"> →</span>
      </a>
    
  </div>

    <!-- NAV END -->
    <!-- 打赏 START -->
    
      <div class="money-like">
        <div class="reward-btn">
          赏
          <span class="money-code">
            <span class="alipay-code">
              <div class="code-image"></div>
              <b>使用支付宝打赏</b>
            </span>
            <span class="wechat-code">
              <div class="code-image"></div>
              <b>使用微信打赏</b>
            </span>
          </span>
        </div>
        <p class="notice">点击上方按钮,请我喝杯咖啡！</p>
      </div>
    
    <!-- 打赏 END -->
    <!-- 二维码 START -->
    
      <div class="qrcode">
        <canvas id="share-qrcode"></canvas>
        <p class="notice">扫描二维码，分享此文章</p>
      </div>
    
    <!-- 二维码 END -->
    
      <!-- Gitment START -->
      <div id="comments"></div>
      <!-- Gitment END -->
    
  </article>
  <!-- Article END -->
  <!-- Catalog START -->
  
    <aside class="catalog-container">
  <div class="toc-main">
  <!-- 不蒜子统计 -->
    <strong class="toc-title">目录</strong>
    
      <ol class="toc-nav"><li class="toc-nav-item toc-nav-level-1"><a class="toc-nav-link" href="#1-延时从库"><span class="toc-nav-text">1. 延时从库</span></a><ol class="toc-nav-child"><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#1-1介绍"><span class="toc-nav-text">1.1介绍</span></a></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#1-2-为什么要有延时从"><span class="toc-nav-text">1.2 为什么要有延时从</span></a></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#1-3-配置延时从库"><span class="toc-nav-text">1.3 配置延时从库</span></a></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#1-4-延时从库应用"><span class="toc-nav-text">1.4 延时从库应用</span></a><ol class="toc-nav-child"><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#1-4-1-故障恢复思路"><span class="toc-nav-text">1.4.1 故障恢复思路</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#1-4-2-故障模拟及恢复"><span class="toc-nav-text">1.4.2 故障模拟及恢复</span></a></li></ol></li></ol></li><li class="toc-nav-item toc-nav-level-1"><a class="toc-nav-link" href="#2-半同步"><span class="toc-nav-text">2. 半同步            ***</span></a><ol class="toc-nav-child"><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#2-1-半同步复制工作原理的变化"><span class="toc-nav-text">2.1 半同步复制工作原理的变化</span></a></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#2-2-配置半同步复制"><span class="toc-nav-text">2.2 配置半同步复制</span></a></li></ol></li><li class="toc-nav-item toc-nav-level-1"><a class="toc-nav-link" href="#3-过滤复制"><span class="toc-nav-text">3 . 过滤复制</span></a><ol class="toc-nav-child"><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#3-1-说明"><span class="toc-nav-text">3.1 说明</span></a></li></ol></li><li class="toc-nav-item toc-nav-level-1"><a class="toc-nav-link" href="#4-GTID复制"><span class="toc-nav-text">4. GTID复制</span></a><ol class="toc-nav-child"><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#4-1-GTID引入"><span class="toc-nav-text">4.1  GTID引入</span></a></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#4-2-GTID介绍"><span class="toc-nav-text">4.2 GTID介绍</span></a></li></ol></li><li class="toc-nav-item toc-nav-level-1"><a class="toc-nav-link" href="#4-3-GTID核心参数"><span class="toc-nav-text">4.3 GTID核心参数</span></a><ol class="toc-nav-child"><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#4-4-GTID复制配置过程："><span class="toc-nav-text">4.4  GTID复制配置过程：</span></a><ol class="toc-nav-child"><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#4-4-1-清理环境"><span class="toc-nav-text">4.4.1 清理环境</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#4-4-2-准备配置文件"><span class="toc-nav-text">4.4.2 准备配置文件</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#4-4-3-初始化数据"><span class="toc-nav-text">4.4.3 初始化数据</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#4-4-4-启动数据库"><span class="toc-nav-text">4.4.4 启动数据库</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#4-4-5-构建主从："><span class="toc-nav-text">4.4.5 构建主从：</span></a></li></ol></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#4-5-GTID-从库误写入操作处理"><span class="toc-nav-text">4.5 GTID 从库误写入操作处理</span></a></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#4-6-GTID-复制和普通复制的区别"><span class="toc-nav-text">4.6  GTID 复制和普通复制的区别</span></a></li></ol></li></ol>
    
  </div>
</aside>
  
  <!-- Catalog END -->
</main>

<script>
  (function () {
    var url = 'http://www.liuqingzheng.top/db/MySQL系列/09-MySQL系列之-主从复制进阶/';
    var banner = ''
    if (banner !== '' && banner !== 'undefined' && banner !== 'null') {
      $('#article-banner').css({
        'background-image': 'url(' + banner + ')'
      })
    } else {
      $('#article-banner').geopattern(url)
    }
    $('.header').removeClass('fixed-header')

    // error image
    $(".markdown-content img").on('error', function() {
      $(this).attr('src', 'http://file.muyutech.com/error-img.png')
      $(this).css({
        'cursor': 'default'
      })
    })

    // zoom image
    $(".markdown-content img").on('click', function() {
      var src = $(this).attr('src')
      if (src !== 'http://file.muyutech.com/error-img.png') {
        var imageW = $(this).width()
        var imageH = $(this).height()

        var zoom = ($(window).width() * 0.95 / imageW).toFixed(2)
        zoom = zoom < 1 ? 1 : zoom
        zoom = zoom > 2 ? 2 : zoom
        var transY = (($(window).height() - imageH) / 2).toFixed(2)

        $('body').append('<div class="image-view-wrap"><div class="image-view-inner"><img src="'+ src +'" /></div></div>')
        $('.image-view-wrap').addClass('wrap-active')
        $('.image-view-wrap img').css({
          'width': `${imageW}`,
          'transform': `translate3d(0, ${transY}px, 0) scale3d(${zoom}, ${zoom}, 1)`
        })
        $('html').css('overflow', 'hidden')

        $('.image-view-wrap').on('click', function() {
          $(this).remove()
          $('html').attr('style', '')
        })
      }
    })
  })();
</script>


  <script>
    var qr = new QRious({
      element: document.getElementById('share-qrcode'),
      value: document.location.href
    });
  </script>



  <script>
    var gitmentConfig = "liuqingzheng";
    if (gitmentConfig !== 'undefined') {
      var gitment = new Gitment({
        id: "db/MySQL系列/09-MySQL系列之-主从复制进阶",
        owner: "liuqingzheng",
        repo: "FuckBlog",
        oauth: {
          client_id: "32a4076431cf39d0ecea",
          client_secret: "94484bd79b3346a949acb2fda3c8a76ce16990c6"
        },
        theme: {
          render(state, instance) {
            const container = document.createElement('div')
            container.lang = "en-US"
            container.className = 'gitment-container gitment-root-container'
            container.appendChild(instance.renderHeader(state, instance))
            container.appendChild(instance.renderEditor(state, instance))
            container.appendChild(instance.renderComments(state, instance))
            container.appendChild(instance.renderFooter(state, instance))
            return container;
          }
        }
      })
      gitment.render(document.getElementById('comments'))
    }
  </script>




    <div class="scroll-top">
  <span class="arrow-icon"></span>
</div>
    <footer class="app-footer">
<!-- 不蒜子统计 -->
<span id="busuanzi_container_site_pv">
     本站总访问量<span id="busuanzi_value_site_pv"></span>次
</span>
<span class="post-meta-divider">|</span>
<span id="busuanzi_container_site_uv" style='display:none'>
     本站访客数<span id="busuanzi_value_site_uv"></span>人
</span>
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>



  <p class="copyright">
    &copy; 2021 | Proudly powered by <a href="https://www.cnblogs.com/xiaoyuanqujing" target="_blank">小猿取经</a>
    <br>
    Theme by <a href="https://www.cnblogs.com/xiaoyuanqujing" target="_blank" rel="noopener">小猿取经</a>
  </p>
</footer>

<script>
  function async(u, c) {
    var d = document, t = 'script',
      o = d.createElement(t),
      s = d.getElementsByTagName(t)[0];
    o.src = u;
    if (c) { o.addEventListener('load', function (e) { c(null, e); }, false); }
    s.parentNode.insertBefore(o, s);
  }
</script>
<script>
  async("//cdnjs.cloudflare.com/ajax/libs/fastclick/1.0.6/fastclick.min.js", function(){
    FastClick.attach(document.body);
  })
</script>

<script>
  var hasLine = 'true';
  async("//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js", function(){
    $('figure pre').each(function(i, block) {
      var figure = $(this).parents('figure');
      if (hasLine === 'false') {
        figure.find('.gutter').hide();
      }
      var lang = figure.attr('class').split(' ')[1] || 'code';
      var codeHtml = $(this).html();
      var codeTag = document.createElement('code');
      codeTag.className = lang;
      codeTag.innerHTML = codeHtml;
      $(this).attr('class', '').empty().html(codeTag);
      figure.attr('data-lang', lang.toUpperCase());
      hljs.highlightBlock(block);
    });
  })
</script>





<!-- Baidu Tongji -->

<script>
    var _baId = 'c5fd96eee1193585be191f318c3fa725';
    // Originial
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?" + _baId;
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
</script>


<script src="/js/script.js"></script>


<script src="/js/search.js"></script>


<script src="/js/load.js"></script>



  <span class="local-search local-search-google local-search-plugin" style="right: 50px;top: 70px;;position:absolute;z-index:2;">
      <input type="search" placeholder="站内搜索" id="local-search-input" class="local-search-input-cls" style="">
      <div id="local-search-result" class="local-search-result-cls"></div>
  </span>


  </body>
</html>